using System;
using System.Collections.Generic;

using lucere.io;

namespace lucere.index
{
    ///<summary>
    /// Information about a segment such as it's name, directory, and files related to the segment.
    ///</summary>
    public interface ISegmentInfo : ICloneable
    {
        /// <summary>
        /// unique name in dir
        /// </summary>
        string Name { get; set; } 

        /// <summary>
        /// number of docs in seg
        /// </summary>
        int DocumentCount { get; set; } 

        /// <summary>
        /// where segment resides
        /// </summary>
        IDirectory Directory { get; set; }

        /// <summary>
        /// total byte size of all of our files (computed on demand)
        /// </summary>
        long SizeInBytes { get; set; }
   
        /// <summary>
        /// Copy everything from src SegmentInfo into our instance.
        /// </summary>
        /// <param name="src"></param>
        void Reset(ISegmentInfo src);
    
        IDictionary<string, string> Diagnostics { get; set; } 

        void SetFieldCount(int fieldCount);

        bool HasDeletions { get; } 
    
        void AdvanceDeleteGeneration();

        void ClearDeleteGeneration();

        string DeleteFilename { get; }
   
        /// <summary>
        /// Returns true if this field for this segment has saved a separate norms file (_<segment>_N.sX).
        /// </summary>
        /// <param name="fieldNumber">the field index to check</param>
        /// <returns></returns>
        bool HasSeparateNorms(int fieldNumber);

        /// <summary>
        /// Returns true if any fields in this segment have separate norms.
        /// </summary>
        /// <returns></returns>
        bool HasSeparateNorms();
    
        /// <summary>
        /// Increment the generation count for the norms file for this field.
        /// </summary>
        /// <param name="fieldIndex">field whose norm file will be rewritten</param>
        void AdvanceNormGeneration(int fieldIndex);
  
        /// <summary>
        /// Get the file name for the norms file for this field. 
        /// </summary>
        /// <param name="number">field index</param>
        /// <returns></returns>
        string GetNormFilename(int number);
    
        /// <summary>
        /// Mark whether this segment is stored as a compound file.
        /// </summary>
        bool UseCompoundFile { get; set; } 
    

        int DeleteCount { get; set; } 

        int DocumentStoreOffset { get; } 
  
        bool DocumentStoreIsCompoundFile { get; set; }
  
        string DocumentStoreSegment { get; set; }

        void SetDocumentStore(int offset, string segment, bool isCompoundFile);

        /// <summary>
        /// Save this segment's info.
        /// </summary>
        /// <param name="output"></param>
        void Write(IIndexOutput output);

        bool HasProximiityData { get; set; } 

        /// <summary>
        /// Return all files referenced by this SegmentInfo.  
        /// The returns List is a locally cached List so you should not modify it.
        /// </summary>
        IList<String> Files { get; } 

        /// <summary>
        /// Used for debugging 
        /// </summary>
        /// <param name="dir"></param>
        /// <returns></returns>
        string SegString(IDirectory directory);
    }
}